﻿//----------------------------------------------------------------
// Desc: 
// Edit: ShowLong, http://blog.csdn.net/showlong
//
// Date Created: 2009-10-19
//
// Update Date : 
//
// Copyright (c) Fuel4D (http://www.fuel4d.com), All rights reserved.
//
//----------------------------------------------------------------
#pragma once


class FAPI FUI_Button : public FUI_Object
{
    FUI_DECLARE_CLASS(FUI_Button)

    friend class FUI_Combo;
    friend class FUI_ScrollBar;
    friend class FUI_ScrollBarEx;
    friend class FUI_Slider;
    friend class FUI_SliderEx;
    friend class FUI_Container;

public:
    FUI_Button(EF_UI_WIDGET_TYPE t = eUWT_Button);
    virtual void Render(EF_UI_RENDER_LAYER layer);
    virtual void SetEnable(bool bEnable);
    virtual bool IsEnable(){ return nButtonState != eUBS_Disable; }
    virtual bool OnMouseMove(funit nX, funit nY);
    virtual bool OnLButtonDown(funit nX, funit nY);
    virtual bool OnLButtonUp(funit nX, funit nY);
    virtual void OnMoveOut();

    // 自动刷新状态
    void RefButtonState();
    // 设置普通时图片
    void SetNormalPic();
    // 设置悬停时图片
    void SetSuspendPic();
    // 设置按下时图片
    void SetPressPic();
    // 设置图片组（即更换按钮图片）
    void SetButtonGroup(WORD index);

    // 是否是按下状态
    FINLINE bool IsPress(){ return nButtonState == eUBS_Press; }
    // 设置启动鼠标
    FINLINE void EnableMouseEvent(bool bMove){ pButtonData->SetDisableState(!bMove); }
    // 鼠标事件是否可用
    FINLINE bool IsEnableMouseEvent(){ return !pButtonData->IsDisableState(); }

protected:
    virtual void InitUIData(FUI_Object* father, fuWidgetBase* pData, FUI_Layout* layout);

protected:
    fuWidgetButton* pButtonData;// 控件数据地址
    BYTE nButtonState;          // 按钮当前状态
};